<template>
    <div class="layerRtb layerRtb-threecolumn">
        <three-title :title="{name:'基础'}"></three-title>
        <div class="layerRtb-scroll thinScroll" v-scrollHeight="437">
            <div class="analyItem">
                <p class="analyItemTit tx-center" :class="((userInfo.u_name=== undefined || userInfo.u_name=== '' || userInfo.u_name=== null) ||
                    (userInfo.phone === undefined || userInfo.phone === '' || userInfo.phone === null) ||
                    (userInfo.weixin === undefined || userInfo.weixin === '' || userInfo.weixin === null) ||
                    (userInfo.sex=== undefined || userInfo.sex=== '' || userInfo.sex=== null)) ? '' : 'analyLightGreen'">基本资料</p>
                <div class="analyItemCon" v-if="flg==1">
                    <!-- <div>{{stageInfo.user_name}}</div> -->
                <p class="col-md-6">姓名：<span class="cLightGray pr8">{{userInfo.u_name ? userInfo.u_name : ''}}</span></p >
                <p class="col-md-6">电话：<span class="cLightGray pr8">{{userInfo.phone ? userInfo.phone : ''}}</span></p >
                <p class="col-md-6">微信：<span class="cLightGray pr8">{{userInfo.weixin ? userInfo.weixin : ''}}</span></p >
                <p class="col-md-6">性别：<span class="cLightGray pr8">{{userInfo.sex ? userInfo.sex : ''}}</span></p >
                    <div class="imgbox imgbox1 col-md-2"  style="margin-top: 15px;">
                        <img src="https://gnr.rxjy.com/hrms/static/modules/cur/images/edit_img.png" title="编辑" width="20" class="fr pointer mr5" @click="flg=0">
                    </div>
                </div>
                <div class="analyItemCon" v-else>
                    <div class="textBoxtxt " >
                        <p class="col-md-5" style="line-height: 45px;">
                            <span class="cLightGray pr8">姓名</span>
                            <input v-model="userName" type="text" class="evaluateStandard" style="width: 80px;" value="">
                        </p>
                        <p class="col-md-5 " style="line-height: 45px;">
                            <span class="cLightGray pr8">电话</span>
                            <input v-model="phone" type="text" class="width120 evaluateStandard" value="">
                        </p>
                        <p class="col-md-5" style="line-height: 45px;">
                            <span class="cLightGray pr8">微信</span>
                            <input v-model="weChat" type="text" class="width80 evaluateStandard" value="">
                        </p>
                        <p class="col-md-5" style="line-height: 45px;">
                            <span class="cLightGray pr8">性别</span>
                            <select v-model="sex" name="set_userInfo_sex" class="width80">
                                <option value="1">男</option>
                                <option value="0">女</option>
                            </select>
                        </p>
                        <!-- <p class="col-md-4" style="padding-top: 10px;">
                            <span class="cLightGray pr8">推荐人</span>
                            <select name="set_userInfo_tuijianren" class="width80">
                                <option value=""></option>
                                <option value="g00008372">盛斌</option>
                                <option value="g00008373">朱又军</option>
                            </select>
                        </p> -->
                    </div>
                    <div class="imgbox imgbox2 " style="margin-top: 15px;margin-right: -10px">
                        <img @click='OperateAppUser()' src="https://gnr.rxjy.com/hrms/static/modules/cur/images/save_img.png" title="保存" width="20" class="fl pointer mr5" name="update_stage_info_intention">
                        <img src="https://gnr.rxjy.com/hrms/static/modules/cur/images/goback_img.png" title="返回" width="20" class="fl pointer mr5" @click="flg=1">
                    </div>
                </div>
            </div>
            <div class="analyItem">
                <p class="analyItemTit tx-center" :class="((pmUserInfo.work_type=== undefined || pmUserInfo.work_type=== '' || pmUserInfo.work_type=== null) ||
                    (pmUserInfo.worker_year=== undefined || pmUserInfo.worker_year=== '' || pmUserInfo.worker_year=== null) ||
                    (pmUserInfo.worker_number=== undefined || pmUserInfo.worker_number === '' || pmUserInfo.worker_number === null)) ? '' : 'analyLightGreen'">行业经验</p>
                <div class="analyItemCon" v-if="flgTwo==1">
               <p class="col-md-6">行业经验：<span class="cLightGray pr8">{{pmUserInfo.worker_year ? pmUserInfo.worker_year : ''}}</span></p >
                <p class="col-md-6">固定工人：<span class="cLightGray pr8">{{pmUserInfo.worker_number ? pmUserInfo.worker_number : ''}}</span></p >
                <p class="col-md-6">从事类型：<span class="cLightGray pr8">{{pmUserInfo.work_type ? pmUserInfo.work_type : ''}}</span></p >
                <p class="fl col-md-6">
                    <span class="cLightGray pr8" style="width: 76px;">行业出身</span><span>
                                <select v-model="self_job" class="widthB60" id="self_job3" disabled="disabled">
                                        <option ng-repeat="li in gongzhong" value="0" class="ng-binding ng-scope">请选择工种</option>
                                        <option ng-repeat="li in gongzhong" value="1" class="ng-binding ng-scope">瓦工</option>
                                        <option ng-repeat="li in gongzhong" value="2" class="ng-binding ng-scope">木工</option>
                                        <option ng-repeat="li in gongzhong" value="3" class="ng-binding ng-scope">油工</option>
                                        <option ng-repeat="li in gongzhong" value="4" class="ng-binding ng-scope">电工</option>
                                        <option ng-repeat="li in gongzhong" value="5" class="ng-binding ng-scope">暖通</option>
                                        <option ng-repeat="li in gongzhong" value="6" class="ng-binding ng-scope">焊工</option>
                                        <option ng-repeat="li in gongzhong" value="7" class="ng-binding ng-scope">壮工</option>
                                        <option ng-repeat="li in gongzhong" value="8" class="ng-binding ng-scope">安装</option>
                                        <option ng-repeat="li in gongzhong" value="9" class="ng-binding ng-scope">拆除</option>
                                        <option ng-repeat="li in gongzhong" value="10" class="ng-binding ng-scope">搬运</option>
                                        <option ng-repeat="li in gongzhong" value="11" class="ng-binding ng-scope">家具</option>
                                        <option ng-repeat="li in gongzhong" value="12" class="ng-binding ng-scope">弱电</option>
                                        <option ng-repeat="li in gongzhong" value="13" class="ng-binding ng-scope">水暖成品安装</option>
                                        <option ng-repeat="li in gongzhong" value="14" class="ng-binding ng-scope">电气成品安装</option>
                                        <option ng-repeat="li in gongzhong" value="88" class="ng-binding ng-scope">装饰成品安装</option>
                                        <option ng-repeat="li in gongzhong" value="100" class="ng-binding ng-scope">其他</option>
                                        <option ng-repeat="li in gongzhong" value="15" class="ng-binding ng-scope">水工</option>
                                        <option ng-repeat="li in gongzhong" value="16" class="ng-binding ng-scope">经理</option>
                                        <!-- <option ng-repeat="li in gongzhong" value="0" class="ng-binding ng-scope">监理</option> -->
                                </select>
                    </span>
                </p>
                    <div class="imgbox imgbox1 col-md-3" style="margin-top: 15px;">
                        <img src="https://gnr.rxjy.com/hrms/static/modules/cur/images/edit_img.png" title="编辑" width="20" class="fr pointer mr5" @click="flgTwo=0">
                    </div>
                </div>
                <div class="analyItemCon" v-else>
                        <div class="textBoxtxt hide" style="display: block;">
                                        <p class="fl col-md-5" style="line-height: 45px;">
                                            <span class="cLightGray pr8">行业经验</span>
                                            <input v-model="worker_year" type="text" class="width60 evaluateStandard" name="set_userInfo_u_jyshijian" > 年
                                        </p>
                                        <p class="fl col-md-5" style="line-height: 45px;">
                                            <span class="cLightGray pr8">固定工人</span>
                                            <input v-model="worker_number"  type="text" class="width60 evaluateStandard" name="set_userInfo_u_worker" > 人
                                        </p>
                                        <p class="fl col-md-5" style="line-height: 45px;">
                                            <span class="cLightGray pr8">从事类型</span>
                                            <input v-model="work_type"  type="text" class="width60 evaluateStandard" name="set_userInfo_u_worker" >
                                        </p>
                                        <p class="fl col-md-5" style="line-height: 45px;">
                                            <span  class="cLightGray pr8" style="width: 76px;">行业出身</span><span>
                                                    <select v-model="self_job" class="widthB60" id="self_job2">
                                                        <option ng-repeat="li in gongzhong" value="0" class="ng-binding ng-scope">请选择工种</option>
                                                        <option ng-repeat="li in gongzhong" value="1" class="ng-binding ng-scope">瓦工</option>
                                                        <option ng-repeat="li in gongzhong" value="2" class="ng-binding ng-scope">木工</option>
                                                        <option ng-repeat="li in gongzhong" value="3" class="ng-binding ng-scope">油工</option>
                                                        <option ng-repeat="li in gongzhong" value="4" class="ng-binding ng-scope">电工</option>
                                                        <option ng-repeat="li in gongzhong" value="5" class="ng-binding ng-scope">暖通</option>
                                                        <option ng-repeat="li in gongzhong" value="6" class="ng-binding ng-scope">焊工</option>
                                                        <option ng-repeat="li in gongzhong" value="7" class="ng-binding ng-scope">壮工</option>
                                                        <option ng-repeat="li in gongzhong" value="8" class="ng-binding ng-scope">安装</option>
                                                        <option ng-repeat="li in gongzhong" value="9" class="ng-binding ng-scope">拆除</option>
                                                        <option ng-repeat="li in gongzhong" value="10" class="ng-binding ng-scope">搬运</option>
                                                        <option ng-repeat="li in gongzhong" value="11" class="ng-binding ng-scope">家具</option>
                                                        <option ng-repeat="li in gongzhong" value="12" class="ng-binding ng-scope">弱电</option>
                                                        <option ng-repeat="li in gongzhong" value="13" class="ng-binding ng-scope">水暖成品安装</option>
                                                        <option ng-repeat="li in gongzhong" value="14" class="ng-binding ng-scope">电气成品安装</option>
                                                        <option ng-repeat="li in gongzhong" value="88" class="ng-binding ng-scope">装饰成品安装</option>
                                                        <option ng-repeat="li in gongzhong" value="100" class="ng-binding ng-scope">其他</option>
                                                        <option ng-repeat="li in gongzhong" value="15" class="ng-binding ng-scope">水工</option>
                                                        <option ng-repeat="li in gongzhong" value="16" class="ng-binding ng-scope">经理</option>
                                                        <!-- <option ng-repeat="li in gongzhong" value="0" class="ng-binding ng-scope">监理</option> -->
                                                    </select>
                                            </span>
                                        </p>
                            </div>
                        <div class="imgbox imgbox2 " style="margin-top: 15px;margin-right: -10px">
                            <img @click='updUserInfoNew2' src="https://gnr.rxjy.com/hrms/static/modules/cur/images/save_img.png" title="保存" width="20" class="fl pointer mr5" name="update_stage_info_intention" onclick="saveThis(this)">
                            <img src="https://gnr.rxjy.com/hrms/static/modules/cur/images/goback_img.png" title="返回" width="20" class="fl pointer mr5" @click="flgTwo=1">
                        </div>
                </div>
            </div>

            </div>
        <!-- </div> -->
        <div class="layerRtb-footer">
              <div class="analyItem">
                <p class="analyItemTit tx-center">综合</p>
                <div class="analyItemCon">
                    <p class="fl">
                        <span v-if="(userInfo.u_name=== undefined || userInfo.u_name=== '' || userInfo.u_name=== null) ||
                        (userInfo.phone === undefined || userInfo.phone === '' || userInfo.phone === null) ||
                        (userInfo.weixin === undefined || userInfo.weixin === '' || userInfo.weixin === null) ||
                        (userInfo.sex=== undefined || userInfo.sex=== '' || userInfo.sex=== null) ||
                        (pmUserInfo.work_type=== undefined || pmUserInfo.work_type=== '' || pmUserInfo.work_type=== null) ||
                        (pmUserInfo.worker_year=== undefined || pmUserInfo.worker_year=== '' || pmUserInfo.worker_year=== null) ||
                        (pmUserInfo.worker_number=== undefined || pmUserInfo.worker_number === '' || pmUserInfo.worker_number === null)" class="circlemark circlemark-lightRed">待</span>
                        <span v-else class="circlemark circlemark-lightGreen">全</span>
                    </p>
                </div>
            </div>
        </div>
          <transition-group class="animated faster" enter-active-class="animated faster slideInRight" leave-active-class="animated faster slideOutRight">
         </transition-group>
         <transition-group class="animated faster" enter-active-class="animated faster slideInRight" leave-active-class="animated faster slideOutRight">
         </transition-group>
    </div>
</template>
<script>
import { mapGetters, mapMutations } from 'vuex'
import { updUserInfoNew, updatePmUserInfoManager, OperateAppUser } from '../../Resources/Api/index'
export default {
    components: {
    },
    data () {
        return {
            userInfo: {},
            work_type: '', // 从事类型
            worker_year: 0,
            worker_number: 0,
            self_job: 0,
            pmUserInfo: {},
            flgTwo: 1,
            flg: 1,
            stageInfo: {},
            phone: '',
            weChat: '',
            sex: '0',
            userName: ''
        }
    },
    created () {
        this.stageInfo = this.$route.query.stageInfo
        this.pmUserInfo = this.$route.query.pmUserInfo
        this.userInfo = this.$route.query.userInfo
        this.userName = this.userInfo.u_name
        this.phone = this.userInfo.phone
        this.weChat = this.userInfo.weixin
        if (this.userInfo.sex === '男') {
            this.sex = 1
        } else {
            this.sex = 0
        }
        this.self_job = this.pmUserInfo.self_job
        this.worker_year = this.pmUserInfo.worker_year
        this.worker_number = this.pmUserInfo.worker_number
        this.work_type = this.pmUserInfo.work_type
        // this.selectPmUserInfoManager()
    },
    methods: {
        updUserInfoNew2 () {
            if (this.worker_number === null || this.worker_number === '') {
                layer.msg('请输入固定工人')
            }
            if (this.worker_year === null || this.worker_year === '') {
                layer.msg('请输入工龄')
            }
            if (this.work_type === null || this.work_type === '') {
                layer.msg('请输入从事类型')
            }
            updUserInfoNew({
                uid: this.leftInfo.uid,
                workerNumber: this.worker_number,
                workerYear: this.worker_year,
                workType: this.work_type
            }).then(res => {
                if (res.data.StatusCode === 0) {
                    this.updatePmUserInfoManager()
                }
            }).catch(err => {
                console.log(err)
            })
        },
        updatePmUserInfoManager () {
            if (this.self_job === null || this.self_job === '') {
                layer.msg('请选择工种')
                return
            }
            updatePmUserInfoManager({
                uid: this.leftInfo.uid,
                selfJob: this.self_job
            }).then(result => {
                if (result.data.StatusCode === 0) {
                    layer.msg('更新成功')
                    this.$router.push(this.$route.matched[1].path)
                    // this.selectPmUserInfoList.workerNumber = this.number
                    // this.selectPmUserInfoList.workerYear = this.year
                }
            })
        },
        // 根据阶段ID查询该阶段的所有标准
        // selectPmUserInfoManager () {
        //     selectPmUserInfoManager({
        //         uid: this.leftInfo.uid// this.leftInfo.uid //this.leftInfo.uid //
        //     }).then(result => {
        //         this.pmUserInfo = result.data.Body
        //     }).catch(err => {
        //         console.log(err)
        //     })
        // },
        ...mapMutations({
            setUpdateLeft: `SET_UPDATE_LEFT`,
            setUpdatePlate: `SET_UPDATE_PLATE`
        }),
        OperateAppUser () {
            let sexx
            if (Number(this.sex) === 0) {
                sexx = '女'
            } else {
                sexx = '男'
            }
            OperateAppUser({
                u_name: this.userName,
                phone: this.phone,
                sex: sexx,
                weixin: this.weChat,
                app_id: this.leftInfo.rs_app_id
                // u_sheng: projectSheng,
                // u_shengId: projectShengId, // 省id
                // u_shi: city,
                // u_shiId: cityId,
                // post: 4,
                // u_xian: null,
                // u_xianId: null,
                // u_ywyId: '00000079', // 卡号    写死值
                // u_ywy: '徐志林' // 操作人姓名 写死值
                // region_id: company
            }).then((results) => {
                if (Number(results.data.StatusCode) === 0) {
                    this.updUserInfoNew1()
                }
            }).catch(err => {
                console.log(err)
            })
        },
        updUserInfoNew1 () {
            if (this.userName === null || this.userName === '') {
                layer.msg('请输入姓名')
                return
            }
            if (this.phone === null || this.phone === '') {
                layer.msg('请输入手机号')
                return
            }
            if (this.weChat === null || this.weChat === '') {
                layer.msg('请输入微信号')
                return
            }
            updUserInfoNew({
                uid: this.leftInfo.uid,
                userName: this.userName,
                sex: this.sex,
                mobile: this.phone,
                weChat: this.weChat
            }).then(res => {
                if (res.data.StatusCode === 0) {
                    layer.msg('更新成功')
                    this.setUpdateLeft()
                    // this.setUpdatePlate()
                    this.$router.push(this.$route.matched[1].path)
                }
            }).catch(err => {
                console.log(err)
            })
        }
    },
    computed: {
        ...mapGetters(['leftInfo'])
    },
    watch: {
    }
}

</script>
<style  scoped>
    .imgbox {
    position: absolute;
    right: 10px;
    top: 10px;
}
</style>
